/*
 * @Author: SimonCK666 SimonYang223@163.com
 * @Date: 2022-05-06 14:08:01
 * @LastEditors: SimonCK666 SimonYang223@163.com
 * @LastEditTime: 2022-05-06 14:27:39
 * @FilePath: \golang-concept\L1_goFlow\for.go
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
package main

import "fmt"

func for_opt() {
	x := [...]int{1, 2, 3}

	// map
	m := make(map[string]string, 0)
	m["name"] = "Simon"
	m["age"] = "21"

	// for loop
	for i := 0; i < len(x); i++ {
		fmt.Printf("I: %v V: %v\n", i, x[i])
	}

	// for .. range
	for i, v := range x {
		fmt.Printf("I: %v V: %v\n", i, v)
	}

	for key, val := range m {
		fmt.Printf("Key: %v Val: %v\n", key, val)
	}
}
